// $ANTLR 3.1.1 LPMEDLuaCodeGen.g 2009-10-05 23:27:48
// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 168, 219
// Unreachable code detected.
#pragma warning disable 162
namespace  Core.ANTLRGrammars 
{

    using CommonClasses.Utility;
    using Descriptions_DomainModel.Model;
    using System.Collections.Generic;


using System;
using Antlr.Runtime;
using Antlr.Runtime.Tree;using IList 		= System.Collections.IList;
using ArrayList 	= System.Collections.ArrayList;
using Stack 		= Antlr.Runtime.Collections.StackList;

using IDictionary	= System.Collections.IDictionary;
using Hashtable 	= System.Collections.Hashtable;

using Antlr.StringTemplate;
using Antlr.StringTemplate.Language;

public partial class LPMEDLuaCodeGen : TreeParser
{
    public static readonly string[] tokenNames = new string[] 
	{
        "<invalid>", 
		"<EOR>", 
		"<DOWN>", 
		"<UP>", 
		"CPROGRAM", 
		"CDEVICE", 
		"CTYPE", 
		"CBLOCK", 
		"CSTATEMENT", 
		"CIFTE", 
		"CASSIGN", 
		"CWHILE", 
		"CFOR", 
		"CFORDEC", 
		"CUNARMIN", 
		"CMETHODNAME", 
		"CCALL", 
		"CINT", 
		"CFLOAT", 
		"CBOOL", 
		"CSYNCCALL", 
		"CASYNCCALL", 
		"CWAITTHECALL", 
		"CWAITANYCALL", 
		"CENDTHECALL", 
		"OBJECTNAME", 
		"MEMBERNAME", 
		"NODES", 
		"CGETSTATE", 
		"CBREAKPOINT", 
		"CREGMETHACCESS", 
		"CREGFUNCACCESS", 
		"CTERMINATEALL", 
		"CASYNCFUNCCALL", 
		"CSYNCFUNCCALL", 
		"CWAITFUNCFINISH", 
		"CDEFUN", 
		"PARAMS", 
		"PARAM", 
		"TERMINATEALL", 
		"OpIncDec", 
		"OpNegation", 
		"OpUnar", 
		"OpDivMul", 
		"OpAddSub", 
		"OpLogicalA", 
		"OpLogicalB", 
		"OpAnd", 
		"OpOr", 
		"TYPE", 
		"DBOOL", 
		"DEVICE", 
		"STATE", 
		"ENDDEVICE", 
		"INT", 
		"FLOAT", 
		"IF", 
		"THEN", 
		"ELSE", 
		"FOR", 
		"WHILE", 
		"WAIT", 
		"GO", 
		"ENDPRESSURE", 
		"VAR", 
		"BREAKPOINT", 
		"DEFUN", 
		"WS", 
		"NEWLINE", 
		"LINECOMMENT", 
		"ID", 
		"OBRACKET", 
		"CBRACKET", 
		"CURLYOBRACKET", 
		"CURLYCBRACKET", 
		"EQUALS", 
		"DOT", 
		"SEMI", 
		"COLON", 
		"COMMA", 
		"CASSIGNOP", 
		"CPARAM", 
		"DEVICEID", 
		"'('", 
		"')'"
    };

    public const int OpIncDec = 40;
    public const int WHILE = 60;
    public const int OpLogicalA = 45;
    public const int OBJECTNAME = 25;
    public const int OpAnd = 47;
    public const int CPROGRAM = 4;
    public const int OpLogicalB = 46;
    public const int DEVICEID = 82;
    public const int OpNegation = 41;
    public const int CTYPE = 6;
    public const int DBOOL = 50;
    public const int FOR = 59;
    public const int PARAM = 38;
    public const int FLOAT = 55;
    public const int EQUALS = 75;
    public const int OpAddSub = 44;
    public const int CURLYCBRACKET = 74;
    public const int LINECOMMENT = 69;
    public const int ID = 70;
    public const int EOF = -1;
    public const int CASYNCCALL = 21;
    public const int CSYNCFUNCCALL = 34;
    public const int IF = 56;
    public const int TYPE = 49;
    public const int CIFTE = 9;
    public const int CWAITANYCALL = 23;
    public const int CWAITFUNCFINISH = 35;
    public const int THEN = 57;
    public const int CFORDEC = 13;
    public const int COMMA = 79;
    public const int OpDivMul = 43;
    public const int CDEVICE = 5;
    public const int CURLYOBRACKET = 73;
    public const int CSYNCCALL = 20;
    public const int CFOR = 12;
    public const int DEVICE = 51;
    public const int NODES = 27;
    public const int VAR = 64;
    public const int CREGFUNCACCESS = 31;
    public const int CPARAM = 81;
    public const int ENDDEVICE = 53;
    public const int DOT = 76;
    public const int CMETHODNAME = 15;
    public const int CBRACKET = 72;
    public const int PARAMS = 37;
    public const int MEMBERNAME = 26;
    public const int CWHILE = 11;
    public const int STATE = 52;
    public const int DEFUN = 66;
    public const int T__83 = 83;
    public const int OpUnar = 42;
    public const int CTERMINATEALL = 32;
    public const int CREGMETHACCESS = 30;
    public const int ELSE = 58;
    public const int CDEFUN = 36;
    public const int CSTATEMENT = 8;
    public const int CUNARMIN = 14;
    public const int INT = 54;
    public const int WAIT = 61;
    public const int T__84 = 84;
    public const int SEMI = 77;
    public const int CASSIGN = 10;
    public const int COLON = 78;
    public const int CBREAKPOINT = 29;
    public const int CINT = 17;
    public const int WS = 67;
    public const int TERMINATEALL = 39;
    public const int CENDTHECALL = 24;
    public const int NEWLINE = 68;
    public const int OpOr = 48;
    public const int ENDPRESSURE = 63;
    public const int CBLOCK = 7;
    public const int CCALL = 16;
    public const int CASYNCFUNCCALL = 33;
    public const int CGETSTATE = 28;
    public const int GO = 62;
    public const int OBRACKET = 71;
    public const int CBOOL = 19;
    public const int CFLOAT = 18;
    public const int BREAKPOINT = 65;
    public const int CWAITTHECALL = 22;
    public const int CASSIGNOP = 80;

    // delegates
    // delegators



        public LPMEDLuaCodeGen(ITreeNodeStream input)
    		: this(input, new RecognizerSharedState()) {
        }

        public LPMEDLuaCodeGen(ITreeNodeStream input, RecognizerSharedState state)
    		: base(input, state) {
            InitializeCyclicDFAs();

             
        }
        
    protected StringTemplateGroup templateLib =
      new StringTemplateGroup("LPMEDLuaCodeGenTemplates", typeof(AngleBracketTemplateLexer));

    public StringTemplateGroup TemplateLib
    {
     	get { return this.templateLib; }
     	set { this.templateLib = value; }
    }

    /// <summary> Allows convenient multi-value initialization:
    ///  "new STAttrMap().Add(...).Add(...)"
    /// </summary>
    protected class STAttrMap : Hashtable
    {
      public STAttrMap Add(string attrName, object value) 
      {
        base.Add(attrName, value);
        return this;
      }
      public STAttrMap Add(string attrName, int value) 
      {
        base.Add(attrName, value);
        return this;
      }
    }

    override public string[] TokenNames {
		get { return LPMEDLuaCodeGen.tokenNames; }
    }

    override public string GrammarFileName {
		get { return "LPMEDLuaCodeGen.g"; }
    }


    	public string ModuleName;
        	public IList<string> WatchesNames;
    	public DomainModel model;

          	string BoolToStr(bool v)
    	{ 
    		return (v)? "true" : "false";
    	}

    	private Node GetNodeByFullPath(string DevName, IList Nodes)
            {
                NodeGroup dev = model.NodeGroups.Find(obj => obj.Name == DevName);

                Node nod = dev.Nodes.Find(n => n.Name == (Nodes[0] as CommonTree).Text);

                for (int i = 1; i < Nodes.Count; i++ )
                    nod = nod.Nodes.Find(n => n.Name == (Nodes[i] as CommonTree).Text);

                return nod;
            }

          	void FindVPinsByMethodName(
                                     string DDname,
                                     string DEVICEID,
        			         IList nodes,
                                     string sm,
                                     out int statePin, 
    				 out int pout,
                                     out string signal)
          	{
    		Node fnode = GetNodeByFullPath(DEVICEID, nodes);
           
           		// if we are finding THE Method, then we know it's name (sm)
    	       	//if(sm!="*")
    		//{
    		        Method m=fnode.Methods.Find(tm => tm.Name == sm);
    			statePin = fnode.StatePinNumber;
    			pout = m.VirtualPinOut;
    			//signal = BoolToStr(m.Signal);
    			signal = m.Signal.ToString();
    	        //}
    		//else //we are finding all methods in node
    		//{
    		//        pouts=new List<int>(); pins=new List<int>(); 
    		//        foreach(Method m in fnode.Methods)
    		//	{
    		//		pouts.Add(m.VirtualPinOut);
    		//	        pins.Add(m.VirtualPinIn);
    		//	}
    		//	hold = true;
    		//	signal = "true";
    		//return true;
    		//}
    	}//FindVPinsByMethodName
    	
    	int GetNamedStateValue(string devName, IList nodes, string sname)
    	{
    		Node node = GetNodeByFullPath(devName, nodes);

    		return node.NamedStates.Find(nameds => nameds.Name == sname).Value;
    	}

    	int GetStatePinNumber(string devName, IList nodes)
    	{
    		Node node = GetNodeByFullPath(devName, nodes);

    		return node.StatePinNumber;
    	}


    protected class program_scope 
    {
        protected internal string DDname;
    }
    protected Stack program_stack = new Stack();

    public class program_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "program"
    // LPMEDLuaCodeGen.g:92:1: program : ^( CPROGRAM ^( CDEVICE name= ID ) block ) -> program(name=$name.textcodeBlock=$block.st);
    public LPMEDLuaCodeGen.program_return program() // throws RecognitionException [1]
    {   
        program_stack.Push(new program_scope());
        LPMEDLuaCodeGen.program_return retval = new LPMEDLuaCodeGen.program_return();
        retval.Start = input.LT(1);

        CommonTree name = null;
        LPMEDLuaCodeGen.block_return block1 = default(LPMEDLuaCodeGen.block_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:97:1: ( ^( CPROGRAM ^( CDEVICE name= ID ) block ) -> program(name=$name.textcodeBlock=$block.st))
            // LPMEDLuaCodeGen.g:98:2: ^( CPROGRAM ^( CDEVICE name= ID ) block )
            {
            	Match(input,CPROGRAM,FOLLOW_CPROGRAM_in_program71); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	Match(input,CDEVICE,FOLLOW_CDEVICE_in_program74); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	name=(CommonTree)Match(input,ID,FOLLOW_ID_in_program78); if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;
            	if ( state.backtracking == 0 ) 
            	{
            	  ((program_scope)program_stack.Peek()).DDname = ((name != null) ? name.Text : null); ModuleName = ((name != null) ? name.Text : null);
            	}
            	PushFollow(FOLLOW_block_in_program83);
            	block1 = block();
            	state.followingStackPointer--;
            	if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 98:96: -> program(name=$name.textcodeBlock=$block.st)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("program",
            	    new STAttrMap().Add("name", ((name != null) ? name.Text : null)).Add("codeBlock", ((block1 != null) ? block1.ST : null)));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
            program_stack.Pop();
        }
        return retval;
    }
    // $ANTLR end "program"

    public class blockStmt_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "blockStmt"
    // LPMEDLuaCodeGen.g:102:1: blockStmt : ^( CSTATEMENT (s+= stmt )* ) -> statemens(sts=$s);
    public LPMEDLuaCodeGen.blockStmt_return blockStmt() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.blockStmt_return retval = new LPMEDLuaCodeGen.blockStmt_return();
        retval.Start = input.LT(1);

        IList list_s = null;
        RuleReturnScope s = null;
        try 
    	{
            // LPMEDLuaCodeGen.g:102:12: ( ^( CSTATEMENT (s+= stmt )* ) -> statemens(sts=$s))
            // LPMEDLuaCodeGen.g:102:14: ^( CSTATEMENT (s+= stmt )* )
            {
            	Match(input,CSTATEMENT,FOLLOW_CSTATEMENT_in_blockStmt111); if (state.failed) return retval;

            	if ( input.LA(1) == Token.DOWN )
            	{
            	    Match(input, Token.DOWN, null); if (state.failed) return retval;
            	    // LPMEDLuaCodeGen.g:102:28: (s+= stmt )*
            	    do 
            	    {
            	        int alt1 = 2;
            	        int LA1_0 = input.LA(1);

            	        if ( ((LA1_0 >= CSTATEMENT && LA1_0 <= CFOR) || LA1_0 == CCALL || (LA1_0 >= CBREAKPOINT && LA1_0 <= CREGMETHACCESS) || (LA1_0 >= CTERMINATEALL && LA1_0 <= CWAITFUNCFINISH)) )
            	        {
            	            alt1 = 1;
            	        }


            	        switch (alt1) 
            	    	{
            	    		case 1 :
            	    		    // LPMEDLuaCodeGen.g:102:28: s+= stmt
            	    		    {
            	    		    	PushFollow(FOLLOW_stmt_in_blockStmt115);
            	    		    	s = stmt();
            	    		    	state.followingStackPointer--;
            	    		    	if (state.failed) return retval;
            	    		    	if (list_s == null) list_s = new ArrayList();
            	    		    	list_s.Add(s.Template);


            	    		    }
            	    		    break;

            	    		default:
            	    		    goto loop1;
            	        }
            	    } while (true);

            	    loop1:
            	    	;	// Stops C# compiler whining that label 'loop1' has no statements


            	    Match(input, Token.UP, null); if (state.failed) return retval;
            	}


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 102:37: -> statemens(sts=$s)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("statemens",
            	    new STAttrMap().Add("sts", list_s));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "blockStmt"

    public class stmt_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "stmt"
    // LPMEDLuaCodeGen.g:105:1: stmt options {backtrack=true; } : ( assign -> {$assign.st} | ifStmt -> {$ifStmt.st} | ^( CWHILE expr blockStmt ) -> while(expr=$expr.stcodeBlock=$blockStmt.st) | ^( CFOR a= assign expr b= assign blockStmt ) -> for(initassign=$a.stexpr=$expr.stassign=$b.stcodeBlock=$blockStmt.st) | deviceFuncID -> {$deviceFuncID.st} | blockStmt -> {$blockStmt.st} | ^( CBREAKPOINT INT ) -> breakpoint(id=$INT.Text) | regMethodAccess -> {$regMethodAccess.st} | CTERMINATEALL -> terminateall() | functionCall -> {$functionCall.st});
    public LPMEDLuaCodeGen.stmt_return stmt() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.stmt_return retval = new LPMEDLuaCodeGen.stmt_return();
        retval.Start = input.LT(1);

        CommonTree INT10 = null;
        LPMEDLuaCodeGen.assign_return a = default(LPMEDLuaCodeGen.assign_return);

        LPMEDLuaCodeGen.assign_return b = default(LPMEDLuaCodeGen.assign_return);

        LPMEDLuaCodeGen.assign_return assign2 = default(LPMEDLuaCodeGen.assign_return);

        LPMEDLuaCodeGen.ifStmt_return ifStmt3 = default(LPMEDLuaCodeGen.ifStmt_return);

        LPMEDLuaCodeGen.expr_return expr4 = default(LPMEDLuaCodeGen.expr_return);

        LPMEDLuaCodeGen.blockStmt_return blockStmt5 = default(LPMEDLuaCodeGen.blockStmt_return);

        LPMEDLuaCodeGen.expr_return expr6 = default(LPMEDLuaCodeGen.expr_return);

        LPMEDLuaCodeGen.blockStmt_return blockStmt7 = default(LPMEDLuaCodeGen.blockStmt_return);

        LPMEDLuaCodeGen.deviceFuncID_return deviceFuncID8 = default(LPMEDLuaCodeGen.deviceFuncID_return);

        LPMEDLuaCodeGen.blockStmt_return blockStmt9 = default(LPMEDLuaCodeGen.blockStmt_return);

        LPMEDLuaCodeGen.regMethodAccess_return regMethodAccess11 = default(LPMEDLuaCodeGen.regMethodAccess_return);

        LPMEDLuaCodeGen.functionCall_return functionCall12 = default(LPMEDLuaCodeGen.functionCall_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:107:1: ( assign -> {$assign.st} | ifStmt -> {$ifStmt.st} | ^( CWHILE expr blockStmt ) -> while(expr=$expr.stcodeBlock=$blockStmt.st) | ^( CFOR a= assign expr b= assign blockStmt ) -> for(initassign=$a.stexpr=$expr.stassign=$b.stcodeBlock=$blockStmt.st) | deviceFuncID -> {$deviceFuncID.st} | blockStmt -> {$blockStmt.st} | ^( CBREAKPOINT INT ) -> breakpoint(id=$INT.Text) | regMethodAccess -> {$regMethodAccess.st} | CTERMINATEALL -> terminateall() | functionCall -> {$functionCall.st})
            int alt2 = 10;
            switch ( input.LA(1) ) 
            {
            case CASSIGN:
            	{
                alt2 = 1;
                }
                break;
            case CIFTE:
            	{
                alt2 = 2;
                }
                break;
            case CWHILE:
            	{
                alt2 = 3;
                }
                break;
            case CFOR:
            	{
                alt2 = 4;
                }
                break;
            case CCALL:
            	{
                alt2 = 5;
                }
                break;
            case CSTATEMENT:
            	{
                alt2 = 6;
                }
                break;
            case CBREAKPOINT:
            	{
                alt2 = 7;
                }
                break;
            case CREGMETHACCESS:
            	{
                alt2 = 8;
                }
                break;
            case CTERMINATEALL:
            	{
                alt2 = 9;
                }
                break;
            case CASYNCFUNCCALL:
            case CSYNCFUNCCALL:
            case CWAITFUNCFINISH:
            	{
                alt2 = 10;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d2s0 =
            	        new NoViableAltException("", 2, 0, input);

            	    throw nvae_d2s0;
            }

            switch (alt2) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:107:5: assign
                    {
                    	PushFollow(FOLLOW_assign_in_stmt144);
                    	assign2 = assign();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 107:12: -> {$assign.st}
                    	  {
                    	      retval.ST = ((assign2 != null) ? assign2.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:108:5: ifStmt
                    {
                    	PushFollow(FOLLOW_ifStmt_in_stmt154);
                    	ifStmt3 = ifStmt();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 108:12: -> {$ifStmt.st}
                    	  {
                    	      retval.ST = ((ifStmt3 != null) ? ifStmt3.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 3 :
                    // LPMEDLuaCodeGen.g:109:5: ^( CWHILE expr blockStmt )
                    {
                    	Match(input,CWHILE,FOLLOW_CWHILE_in_stmt165); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_stmt167);
                    	expr4 = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_blockStmt_in_stmt169);
                    	blockStmt5 = blockStmt();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 109:30: -> while(expr=$expr.stcodeBlock=$blockStmt.st)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("while",
                    	    new STAttrMap().Add("expr", ((expr4 != null) ? expr4.ST : null)).Add("codeBlock", ((blockStmt5 != null) ? blockStmt5.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 4 :
                    // LPMEDLuaCodeGen.g:110:5: ^( CFOR a= assign expr b= assign blockStmt )
                    {
                    	Match(input,CFOR,FOLLOW_CFOR_in_stmt189); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_assign_in_stmt193);
                    	a = assign();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_stmt195);
                    	expr6 = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_assign_in_stmt199);
                    	b = assign();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_blockStmt_in_stmt201);
                    	blockStmt7 = blockStmt();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 110:46: -> for(initassign=$a.stexpr=$expr.stassign=$b.stcodeBlock=$blockStmt.st)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("for",
                    	    new STAttrMap().Add("initassign", ((a != null) ? a.ST : null)).Add("expr", ((expr6 != null) ? expr6.ST : null)).Add("assign", ((b != null) ? b.ST : null)).Add("codeBlock", ((blockStmt7 != null) ? blockStmt7.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 5 :
                    // LPMEDLuaCodeGen.g:111:5: deviceFuncID
                    {
                    	PushFollow(FOLLOW_deviceFuncID_in_stmt228);
                    	deviceFuncID8 = deviceFuncID();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 111:18: -> {$deviceFuncID.st}
                    	  {
                    	      retval.ST = ((deviceFuncID8 != null) ? deviceFuncID8.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 6 :
                    // LPMEDLuaCodeGen.g:112:5: blockStmt
                    {
                    	PushFollow(FOLLOW_blockStmt_in_stmt238);
                    	blockStmt9 = blockStmt();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 112:15: -> {$blockStmt.st}
                    	  {
                    	      retval.ST = ((blockStmt9 != null) ? blockStmt9.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 7 :
                    // LPMEDLuaCodeGen.g:113:5: ^( CBREAKPOINT INT )
                    {
                    	Match(input,CBREAKPOINT,FOLLOW_CBREAKPOINT_in_stmt249); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	INT10=(CommonTree)Match(input,INT,FOLLOW_INT_in_stmt251); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 113:24: -> breakpoint(id=$INT.Text)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("breakpoint",
                    	    new STAttrMap().Add("id", INT10.Text));
                    	  }

                    	}
                    }
                    break;
                case 8 :
                    // LPMEDLuaCodeGen.g:114:5: regMethodAccess
                    {
                    	PushFollow(FOLLOW_regMethodAccess_in_stmt269);
                    	regMethodAccess11 = regMethodAccess();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 114:21: -> {$regMethodAccess.st}
                    	  {
                    	      retval.ST = ((regMethodAccess11 != null) ? regMethodAccess11.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 9 :
                    // LPMEDLuaCodeGen.g:115:5: CTERMINATEALL
                    {
                    	Match(input,CTERMINATEALL,FOLLOW_CTERMINATEALL_in_stmt279); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 115:19: -> terminateall()
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("terminateall");
                    	  }

                    	}
                    }
                    break;
                case 10 :
                    // LPMEDLuaCodeGen.g:116:5: functionCall
                    {
                    	PushFollow(FOLLOW_functionCall_in_stmt291);
                    	functionCall12 = functionCall();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 116:18: -> {$functionCall.st}
                    	  {
                    	      retval.ST = ((functionCall12 != null) ? functionCall12.ST : null);
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "stmt"

    public class regMethodAccess_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "regMethodAccess"
    // LPMEDLuaCodeGen.g:119:1: regMethodAccess : ^( CREGMETHACCESS ID expr ) -> methodcall(text=$ID.Textvalue=$expr.st);
    public LPMEDLuaCodeGen.regMethodAccess_return regMethodAccess() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.regMethodAccess_return retval = new LPMEDLuaCodeGen.regMethodAccess_return();
        retval.Start = input.LT(1);

        CommonTree ID13 = null;
        LPMEDLuaCodeGen.expr_return expr14 = default(LPMEDLuaCodeGen.expr_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:120:1: ( ^( CREGMETHACCESS ID expr ) -> methodcall(text=$ID.Textvalue=$expr.st))
            // LPMEDLuaCodeGen.g:121:2: ^( CREGMETHACCESS ID expr )
            {
            	Match(input,CREGMETHACCESS,FOLLOW_CREGMETHACCESS_in_regMethodAccess307); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	ID13=(CommonTree)Match(input,ID,FOLLOW_ID_in_regMethodAccess309); if (state.failed) return retval;
            	PushFollow(FOLLOW_expr_in_regMethodAccess311);
            	expr14 = expr();
            	state.followingStackPointer--;
            	if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 121:28: -> methodcall(text=$ID.Textvalue=$expr.st)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("methodcall",
            	    new STAttrMap().Add("text", ID13.Text).Add("value", ((expr14 != null) ? expr14.ST : null)));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "regMethodAccess"

    public class ifStmt_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "ifStmt"
    // LPMEDLuaCodeGen.g:124:1: ifStmt options {backtrack=true; } : ^( CIFTE expr a= blockStmt (b= blockStmt )? ) -> if(expr=$expr.stthen=$a.stelse=(b != null)?$b.st : new StringTemplate(\" \"));
    public LPMEDLuaCodeGen.ifStmt_return ifStmt() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.ifStmt_return retval = new LPMEDLuaCodeGen.ifStmt_return();
        retval.Start = input.LT(1);

        LPMEDLuaCodeGen.blockStmt_return a = default(LPMEDLuaCodeGen.blockStmt_return);

        LPMEDLuaCodeGen.blockStmt_return b = default(LPMEDLuaCodeGen.blockStmt_return);

        LPMEDLuaCodeGen.expr_return expr15 = default(LPMEDLuaCodeGen.expr_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:126:1: ( ^( CIFTE expr a= blockStmt (b= blockStmt )? ) -> if(expr=$expr.stthen=$a.stelse=(b != null)?$b.st : new StringTemplate(\" \")))
            // LPMEDLuaCodeGen.g:127:2: ^( CIFTE expr a= blockStmt (b= blockStmt )? )
            {
            	Match(input,CIFTE,FOLLOW_CIFTE_in_ifStmt347); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	PushFollow(FOLLOW_expr_in_ifStmt349);
            	expr15 = expr();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	PushFollow(FOLLOW_blockStmt_in_ifStmt353);
            	a = blockStmt();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	// LPMEDLuaCodeGen.g:127:28: (b= blockStmt )?
            	int alt3 = 2;
            	int LA3_0 = input.LA(1);

            	if ( (LA3_0 == CSTATEMENT) )
            	{
            	    alt3 = 1;
            	}
            	switch (alt3) 
            	{
            	    case 1 :
            	        // LPMEDLuaCodeGen.g:127:28: b= blockStmt
            	        {
            	        	PushFollow(FOLLOW_blockStmt_in_ifStmt357);
            	        	b = blockStmt();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;

            	        }
            	        break;

            	}


            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 127:40: -> if(expr=$expr.stthen=$a.stelse=(b != null)?$b.st : new StringTemplate(\" \"))
            	  {
            	      retval.ST = templateLib.GetInstanceOf("if",
            	    new STAttrMap().Add("expr", ((expr15 != null) ? expr15.ST : null)).Add("then", ((a != null) ? a.ST : null)).Add("else", (b != null)?((b != null) ? b.ST : null) : new  StringTemplate(" ")));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "ifStmt"

    public class assign_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "assign"
    // LPMEDLuaCodeGen.g:131:1: assign : ^( CASSIGN ID comExpr ) -> assign(left=$ID.Textright=$comExpr.st);
    public LPMEDLuaCodeGen.assign_return assign() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.assign_return retval = new LPMEDLuaCodeGen.assign_return();
        retval.Start = input.LT(1);

        CommonTree ID16 = null;
        LPMEDLuaCodeGen.comExpr_return comExpr17 = default(LPMEDLuaCodeGen.comExpr_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:132:1: ( ^( CASSIGN ID comExpr ) -> assign(left=$ID.Textright=$comExpr.st))
            // LPMEDLuaCodeGen.g:133:2: ^( CASSIGN ID comExpr )
            {
            	Match(input,CASSIGN,FOLLOW_CASSIGN_in_assign387); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	ID16=(CommonTree)Match(input,ID,FOLLOW_ID_in_assign389); if (state.failed) return retval;
            	PushFollow(FOLLOW_comExpr_in_assign391);
            	comExpr17 = comExpr();
            	state.followingStackPointer--;
            	if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 133:24: -> assign(left=$ID.Textright=$comExpr.st)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("assign",
            	    new STAttrMap().Add("left", ID16.Text).Add("right", ((comExpr17 != null) ? comExpr17.ST : null)));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "assign"

    public class comExpr_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "comExpr"
    // LPMEDLuaCodeGen.g:137:1: comExpr : assignExpr -> {$assignExpr.st};
    public LPMEDLuaCodeGen.comExpr_return comExpr() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.comExpr_return retval = new LPMEDLuaCodeGen.comExpr_return();
        retval.Start = input.LT(1);

        LPMEDLuaCodeGen.assignExpr_return assignExpr18 = default(LPMEDLuaCodeGen.assignExpr_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:138:1: ( assignExpr -> {$assignExpr.st})
            // LPMEDLuaCodeGen.g:139:2: assignExpr
            {
            	PushFollow(FOLLOW_assignExpr_in_comExpr417);
            	assignExpr18 = assignExpr();
            	state.followingStackPointer--;
            	if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 139:13: -> {$assignExpr.st}
            	  {
            	      retval.ST = ((assignExpr18 != null) ? assignExpr18.ST : null);
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "comExpr"

    public class assignExpr_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "assignExpr"
    // LPMEDLuaCodeGen.g:143:1: assignExpr : ( ^( CASSIGNOP ID expr ) -> {$expr.st} | expr -> {$expr.st});
    public LPMEDLuaCodeGen.assignExpr_return assignExpr() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.assignExpr_return retval = new LPMEDLuaCodeGen.assignExpr_return();
        retval.Start = input.LT(1);

        LPMEDLuaCodeGen.expr_return expr19 = default(LPMEDLuaCodeGen.expr_return);

        LPMEDLuaCodeGen.expr_return expr20 = default(LPMEDLuaCodeGen.expr_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:144:1: ( ^( CASSIGNOP ID expr ) -> {$expr.st} | expr -> {$expr.st})
            int alt4 = 2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0 == CASSIGNOP) )
            {
                alt4 = 1;
            }
            else if ( ((LA4_0 >= CINT && LA4_0 <= CBOOL) || LA4_0 == OBJECTNAME || LA4_0 == CGETSTATE || LA4_0 == CREGFUNCACCESS || (LA4_0 >= OpNegation && LA4_0 <= OpOr) || LA4_0 == ID || LA4_0 == 83) )
            {
                alt4 = 2;
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                NoViableAltException nvae_d4s0 =
                    new NoViableAltException("", 4, 0, input);

                throw nvae_d4s0;
            }
            switch (alt4) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:145:4: ^( CASSIGNOP ID expr )
                    {
                    	Match(input,CASSIGNOP,FOLLOW_CASSIGNOP_in_assignExpr435); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,ID,FOLLOW_ID_in_assignExpr437); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_assignExpr439);
                    	expr19 = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 145:24: -> {$expr.st}
                    	  {
                    	      retval.ST = ((expr19 != null) ? expr19.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:146:5: expr
                    {
                    	PushFollow(FOLLOW_expr_in_assignExpr448);
                    	expr20 = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 146:10: -> {$expr.st}
                    	  {
                    	      retval.ST = ((expr20 != null) ? expr20.ST : null);
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "assignExpr"

    public class expr_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "expr"
    // LPMEDLuaCodeGen.g:150:1: expr options {backtrack=true; } : ( ^( OpOr a= expr b= expr ) -> template(a=$a.stb=$b.st) << (<a>) or (<b>) >> | ^( OpAnd a= expr b= expr ) -> template(a=$a.stb=$b.st) << (<a>) and (<b>) >> | ^( OpLogicalB a= expr b= expr ) -> template(a=$a.stop=$OpLogicalB.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpLogicalA a= expr b= expr ) -> template(a=$a.stop=$OpLogicalA.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpAddSub a= expr b= expr ) -> template(a=$a.stop=$OpAddSub.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpDivMul a= expr b= expr ) -> template(a=$a.stop=$OpDivMul.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpNegation a= expr ) -> template(a=$a.st) << ~<a> >> | ^( OpUnar a= expr ) -> template(a=$a.st) << -<a> >> | '(' a= expr ')' -> template(a=$a.st) << (<a>) >> | atom -> {$atom.st});
    public LPMEDLuaCodeGen.expr_return expr() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.expr_return retval = new LPMEDLuaCodeGen.expr_return();
        retval.Start = input.LT(1);

        CommonTree OpLogicalB21 = null;
        CommonTree OpLogicalA22 = null;
        CommonTree OpAddSub23 = null;
        CommonTree OpDivMul24 = null;
        LPMEDLuaCodeGen.expr_return a = default(LPMEDLuaCodeGen.expr_return);

        LPMEDLuaCodeGen.expr_return b = default(LPMEDLuaCodeGen.expr_return);

        LPMEDLuaCodeGen.atom_return atom25 = default(LPMEDLuaCodeGen.atom_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:151:1: ( ^( OpOr a= expr b= expr ) -> template(a=$a.stb=$b.st) << (<a>) or (<b>) >> | ^( OpAnd a= expr b= expr ) -> template(a=$a.stb=$b.st) << (<a>) and (<b>) >> | ^( OpLogicalB a= expr b= expr ) -> template(a=$a.stop=$OpLogicalB.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpLogicalA a= expr b= expr ) -> template(a=$a.stop=$OpLogicalA.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpAddSub a= expr b= expr ) -> template(a=$a.stop=$OpAddSub.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpDivMul a= expr b= expr ) -> template(a=$a.stop=$OpDivMul.textb=$b.st) << (<a>) <op> (<b>) >> | ^( OpNegation a= expr ) -> template(a=$a.st) << ~<a> >> | ^( OpUnar a= expr ) -> template(a=$a.st) << -<a> >> | '(' a= expr ')' -> template(a=$a.st) << (<a>) >> | atom -> {$atom.st})
            int alt5 = 10;
            switch ( input.LA(1) ) 
            {
            case OpOr:
            	{
                alt5 = 1;
                }
                break;
            case OpAnd:
            	{
                alt5 = 2;
                }
                break;
            case OpLogicalB:
            	{
                alt5 = 3;
                }
                break;
            case OpLogicalA:
            	{
                alt5 = 4;
                }
                break;
            case OpAddSub:
            	{
                alt5 = 5;
                }
                break;
            case OpDivMul:
            	{
                alt5 = 6;
                }
                break;
            case OpNegation:
            	{
                alt5 = 7;
                }
                break;
            case OpUnar:
            	{
                alt5 = 8;
                }
                break;
            case 83:
            	{
                alt5 = 9;
                }
                break;
            case CINT:
            case CFLOAT:
            case CBOOL:
            case OBJECTNAME:
            case CGETSTATE:
            case CREGFUNCACCESS:
            case ID:
            	{
                alt5 = 10;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d5s0 =
            	        new NoViableAltException("", 5, 0, input);

            	    throw nvae_d5s0;
            }

            switch (alt5) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:152:4: ^( OpOr a= expr b= expr )
                    {
                    	Match(input,OpOr,FOLLOW_OpOr_in_expr474); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr478);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr482);
                    	b = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 152:27: -> template(a=$a.stb=$b.st) << (<a>) or (<b>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) or (<b>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)).Add("b", ((b != null) ? b.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:153:5: ^( OpAnd a= expr b= expr )
                    {
                    	Match(input,OpAnd,FOLLOW_OpAnd_in_expr505); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr509);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr513);
                    	b = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 153:29: -> template(a=$a.stb=$b.st) << (<a>) and (<b>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) and (<b>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)).Add("b", ((b != null) ? b.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 3 :
                    // LPMEDLuaCodeGen.g:154:5: ^( OpLogicalB a= expr b= expr )
                    {
                    	OpLogicalB21=(CommonTree)Match(input,OpLogicalB,FOLLOW_OpLogicalB_in_expr536); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr540);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr544);
                    	b = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 154:34: -> template(a=$a.stop=$OpLogicalB.textb=$b.st) << (<a>) <op> (<b>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) <op> (<b>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)).Add("op", ((OpLogicalB21 != null) ? OpLogicalB21.Text : null)).Add("b", ((b != null) ? b.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 4 :
                    // LPMEDLuaCodeGen.g:155:5: ^( OpLogicalA a= expr b= expr )
                    {
                    	OpLogicalA22=(CommonTree)Match(input,OpLogicalA,FOLLOW_OpLogicalA_in_expr572); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr576);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr580);
                    	b = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 155:34: -> template(a=$a.stop=$OpLogicalA.textb=$b.st) << (<a>) <op> (<b>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) <op> (<b>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)).Add("op", ((OpLogicalA22 != null) ? OpLogicalA22.Text : null)).Add("b", ((b != null) ? b.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 5 :
                    // LPMEDLuaCodeGen.g:156:5: ^( OpAddSub a= expr b= expr )
                    {
                    	OpAddSub23=(CommonTree)Match(input,OpAddSub,FOLLOW_OpAddSub_in_expr608); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr612);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr616);
                    	b = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 156:32: -> template(a=$a.stop=$OpAddSub.textb=$b.st) << (<a>) <op> (<b>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) <op> (<b>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)).Add("op", ((OpAddSub23 != null) ? OpAddSub23.Text : null)).Add("b", ((b != null) ? b.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 6 :
                    // LPMEDLuaCodeGen.g:157:5: ^( OpDivMul a= expr b= expr )
                    {
                    	OpDivMul24=(CommonTree)Match(input,OpDivMul,FOLLOW_OpDivMul_in_expr644); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr648);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr652);
                    	b = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 157:32: -> template(a=$a.stop=$OpDivMul.textb=$b.st) << (<a>) <op> (<b>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) <op> (<b>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)).Add("op", ((OpDivMul24 != null) ? OpDivMul24.Text : null)).Add("b", ((b != null) ? b.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 7 :
                    // LPMEDLuaCodeGen.g:158:5: ^( OpNegation a= expr )
                    {
                    	Match(input,OpNegation,FOLLOW_OpNegation_in_expr680); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr685);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 158:28: -> template(a=$a.st) << ~<a> >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " ~<a> ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 8 :
                    // LPMEDLuaCodeGen.g:159:5: ^( OpUnar a= expr )
                    {
                    	Match(input,OpUnar,FOLLOW_OpUnar_in_expr705); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr709);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 159:23: -> template(a=$a.st) << -<a> >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " -<a> ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 9 :
                    // LPMEDLuaCodeGen.g:160:5: '(' a= expr ')'
                    {
                    	Match(input,83,FOLLOW_83_in_expr728); if (state.failed) return retval;
                    	PushFollow(FOLLOW_expr_in_expr732);
                    	a = expr();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	Match(input,84,FOLLOW_84_in_expr734); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 160:21: -> template(a=$a.st) << (<a>) >>
                    	  {
                    	      retval.ST = new StringTemplate(templateLib, " (<a>) ",
                    	    new STAttrMap().Add("a", ((a != null) ? a.ST : null)));
                    	  }

                    	}
                    }
                    break;
                case 10 :
                    // LPMEDLuaCodeGen.g:161:5: atom
                    {
                    	PushFollow(FOLLOW_atom_in_expr752);
                    	atom25 = atom();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 161:10: -> {$atom.st}
                    	  {
                    	      retval.ST = ((atom25 != null) ? atom25.ST : null);
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "expr"

    protected class atom_scope 
    {
        protected internal int stateValue;
    }
    protected Stack atom_stack = new Stack();

    public class atom_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "atom"
    // LPMEDLuaCodeGen.g:164:1: atom options {backtrack=true; } : ( ID -> {%{$ID.Text}} | ^( CINT INT ) -> {%{$INT.text}} | ^( CBOOL DBOOL ) -> {%{$DBOOL.text}} | ^( CFLOAT FLOAT ) -> {%{$FLOAT.text}} | regFuncAccess -> {$regFuncAccess.st} | ^( OBJECTNAME main= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME name= ID ) -> {%{$atom::stateValue.ToString()}} | ^( CGETSTATE ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ) -> getPinStatus(statepin=GetStatePinNumber($devname.Text, $nodes).ToString()));
    public LPMEDLuaCodeGen.atom_return atom() // throws RecognitionException [1]
    {   
        atom_stack.Push(new atom_scope());
        LPMEDLuaCodeGen.atom_return retval = new LPMEDLuaCodeGen.atom_return();
        retval.Start = input.LT(1);

        CommonTree main = null;
        CommonTree name = null;
        CommonTree devname = null;
        CommonTree ID26 = null;
        CommonTree INT27 = null;
        CommonTree DBOOL28 = null;
        CommonTree FLOAT29 = null;
        CommonTree nodes = null;
        IList list_nodes = null;
        LPMEDLuaCodeGen.regFuncAccess_return regFuncAccess30 = default(LPMEDLuaCodeGen.regFuncAccess_return);



          ((atom_scope)atom_stack.Peek()).stateValue =  0;

        try 
    	{
            // LPMEDLuaCodeGen.g:173:1: ( ID -> {%{$ID.Text}} | ^( CINT INT ) -> {%{$INT.text}} | ^( CBOOL DBOOL ) -> {%{$DBOOL.text}} | ^( CFLOAT FLOAT ) -> {%{$FLOAT.text}} | regFuncAccess -> {$regFuncAccess.st} | ^( OBJECTNAME main= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME name= ID ) -> {%{$atom::stateValue.ToString()}} | ^( CGETSTATE ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ) -> getPinStatus(statepin=GetStatePinNumber($devname.Text, $nodes).ToString()))
            int alt8 = 7;
            switch ( input.LA(1) ) 
            {
            case ID:
            	{
                alt8 = 1;
                }
                break;
            case CINT:
            	{
                alt8 = 2;
                }
                break;
            case CBOOL:
            	{
                alt8 = 3;
                }
                break;
            case CFLOAT:
            	{
                alt8 = 4;
                }
                break;
            case CREGFUNCACCESS:
            	{
                alt8 = 5;
                }
                break;
            case OBJECTNAME:
            	{
                alt8 = 6;
                }
                break;
            case CGETSTATE:
            	{
                alt8 = 7;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d8s0 =
            	        new NoViableAltException("", 8, 0, input);

            	    throw nvae_d8s0;
            }

            switch (alt8) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:174:4: ID
                    {
                    	ID26=(CommonTree)Match(input,ID,FOLLOW_ID_in_atom784); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 174:7: -> {%{$ID.Text}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,ID26.Text);
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:175:5: ^( CINT INT )
                    {
                    	Match(input,CINT,FOLLOW_CINT_in_atom795); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	INT27=(CommonTree)Match(input,INT,FOLLOW_INT_in_atom797); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 175:17: -> {%{$INT.text}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,((INT27 != null) ? INT27.Text : null));
                    	  }

                    	}
                    }
                    break;
                case 3 :
                    // LPMEDLuaCodeGen.g:176:5: ^( CBOOL DBOOL )
                    {
                    	Match(input,CBOOL,FOLLOW_CBOOL_in_atom809); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	DBOOL28=(CommonTree)Match(input,DBOOL,FOLLOW_DBOOL_in_atom811); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 176:20: -> {%{$DBOOL.text}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,((DBOOL28 != null) ? DBOOL28.Text : null));
                    	  }

                    	}
                    }
                    break;
                case 4 :
                    // LPMEDLuaCodeGen.g:177:5: ^( CFLOAT FLOAT )
                    {
                    	Match(input,CFLOAT,FOLLOW_CFLOAT_in_atom823); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	FLOAT29=(CommonTree)Match(input,FLOAT,FOLLOW_FLOAT_in_atom825); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 177:21: -> {%{$FLOAT.text}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,((FLOAT29 != null) ? FLOAT29.Text : null));
                    	  }

                    	}
                    }
                    break;
                case 5 :
                    // LPMEDLuaCodeGen.g:178:5: regFuncAccess
                    {
                    	PushFollow(FOLLOW_regFuncAccess_in_atom836);
                    	regFuncAccess30 = regFuncAccess();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 178:19: -> {$regFuncAccess.st}
                    	  {
                    	      retval.ST = ((regFuncAccess30 != null) ? regFuncAccess30.ST : null);
                    	  }

                    	}
                    }
                    break;
                case 6 :
                    // LPMEDLuaCodeGen.g:179:5: ^( OBJECTNAME main= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME name= ID )
                    {
                    	Match(input,OBJECTNAME,FOLLOW_OBJECTNAME_in_atom848); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	main=(CommonTree)Match(input,ID,FOLLOW_ID_in_atom854); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	Match(input,NODES,FOLLOW_NODES_in_atom858); if (state.failed) return retval;

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	    // LPMEDLuaCodeGen.g:179:43: (nodes+= ID )*
                    	    do 
                    	    {
                    	        int alt6 = 2;
                    	        int LA6_0 = input.LA(1);

                    	        if ( (LA6_0 == ID) )
                    	        {
                    	            alt6 = 1;
                    	        }


                    	        switch (alt6) 
                    	    	{
                    	    		case 1 :
                    	    		    // LPMEDLuaCodeGen.g:179:43: nodes+= ID
                    	    		    {
                    	    		    	nodes=(CommonTree)Match(input,ID,FOLLOW_ID_in_atom864); if (state.failed) return retval;
                    	    		    	if (list_nodes == null) list_nodes = new ArrayList();
                    	    		    	list_nodes.Add(nodes);


                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop6;
                    	        }
                    	    } while (true);

                    	    loop6:
                    	    	;	// Stops C# compiler whining that label 'loop6' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return retval;
                    	}
                    	Match(input,MEMBERNAME,FOLLOW_MEMBERNAME_in_atom869); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	name=(CommonTree)Match(input,ID,FOLLOW_ID_in_atom875); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) 
                    	{
                    	   ((atom_scope)atom_stack.Peek()).stateValue =  GetNamedStateValue(main.Text, list_nodes, name.Text);
                    	}


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 181:5: -> {%{$atom::stateValue.ToString()}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,((atom_scope)atom_stack.Peek()).stateValue.ToString());
                    	  }

                    	}
                    }
                    break;
                case 7 :
                    // LPMEDLuaCodeGen.g:182:5: ^( CGETSTATE ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) )
                    {
                    	Match(input,CGETSTATE,FOLLOW_CGETSTATE_in_atom901); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,OBJECTNAME,FOLLOW_OBJECTNAME_in_atom904); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	devname=(CommonTree)Match(input,ID,FOLLOW_ID_in_atom908); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	Match(input,NODES,FOLLOW_NODES_in_atom912); if (state.failed) return retval;

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	    // LPMEDLuaCodeGen.g:182:55: (nodes+= ID )*
                    	    do 
                    	    {
                    	        int alt7 = 2;
                    	        int LA7_0 = input.LA(1);

                    	        if ( (LA7_0 == ID) )
                    	        {
                    	            alt7 = 1;
                    	        }


                    	        switch (alt7) 
                    	    	{
                    	    		case 1 :
                    	    		    // LPMEDLuaCodeGen.g:182:55: nodes+= ID
                    	    		    {
                    	    		    	nodes=(CommonTree)Match(input,ID,FOLLOW_ID_in_atom916); if (state.failed) return retval;
                    	    		    	if (list_nodes == null) list_nodes = new ArrayList();
                    	    		    	list_nodes.Add(nodes);


                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop7;
                    	        }
                    	    } while (true);

                    	    loop7:
                    	    	;	// Stops C# compiler whining that label 'loop7' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return retval;
                    	}

                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 183:5: -> getPinStatus(statepin=GetStatePinNumber($devname.Text, $nodes).ToString())
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("getPinStatus",
                    	    new STAttrMap().Add("statepin", GetStatePinNumber(devname.Text, list_nodes).ToString()));
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
            atom_stack.Pop();
        }
        return retval;
    }
    // $ANTLR end "atom"

    public class regFuncAccess_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "regFuncAccess"
    // LPMEDLuaCodeGen.g:186:1: regFuncAccess : ^( CREGFUNCACCESS ID ) -> funccall(text=$ID.Text);
    public LPMEDLuaCodeGen.regFuncAccess_return regFuncAccess() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.regFuncAccess_return retval = new LPMEDLuaCodeGen.regFuncAccess_return();
        retval.Start = input.LT(1);

        CommonTree ID31 = null;

        try 
    	{
            // LPMEDLuaCodeGen.g:186:15: ( ^( CREGFUNCACCESS ID ) -> funccall(text=$ID.Text))
            // LPMEDLuaCodeGen.g:186:17: ^( CREGFUNCACCESS ID )
            {
            	Match(input,CREGFUNCACCESS,FOLLOW_CREGFUNCACCESS_in_regFuncAccess942); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	ID31=(CommonTree)Match(input,ID,FOLLOW_ID_in_regFuncAccess944); if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 186:38: -> funccall(text=$ID.Text)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("funccall",
            	    new STAttrMap().Add("text", ID31.Text));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "regFuncAccess"

    public class paramList_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "paramList"
    // LPMEDLuaCodeGen.g:190:1: paramList : ^( CPARAM (e+= expr )+ ) -> paramList(list=$e);
    public LPMEDLuaCodeGen.paramList_return paramList() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.paramList_return retval = new LPMEDLuaCodeGen.paramList_return();
        retval.Start = input.LT(1);

        IList list_e = null;
        RuleReturnScope e = null;
        try 
    	{
            // LPMEDLuaCodeGen.g:190:12: ( ^( CPARAM (e+= expr )+ ) -> paramList(list=$e))
            // LPMEDLuaCodeGen.g:190:14: ^( CPARAM (e+= expr )+ )
            {
            	Match(input,CPARAM,FOLLOW_CPARAM_in_paramList966); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	// LPMEDLuaCodeGen.g:190:24: (e+= expr )+
            	int cnt9 = 0;
            	do 
            	{
            	    int alt9 = 2;
            	    int LA9_0 = input.LA(1);

            	    if ( ((LA9_0 >= CINT && LA9_0 <= CBOOL) || LA9_0 == OBJECTNAME || LA9_0 == CGETSTATE || LA9_0 == CREGFUNCACCESS || (LA9_0 >= OpNegation && LA9_0 <= OpOr) || LA9_0 == ID || LA9_0 == 83) )
            	    {
            	        alt9 = 1;
            	    }


            	    switch (alt9) 
            		{
            			case 1 :
            			    // LPMEDLuaCodeGen.g:190:24: e+= expr
            			    {
            			    	PushFollow(FOLLOW_expr_in_paramList970);
            			    	e = expr();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return retval;
            			    	if (list_e == null) list_e = new ArrayList();
            			    	list_e.Add(e.Template);


            			    }
            			    break;

            			default:
            			    if ( cnt9 >= 1 ) goto loop9;
            			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            		            EarlyExitException eee =
            		                new EarlyExitException(9, input);
            		            throw eee;
            	    }
            	    cnt9++;
            	} while (true);

            	loop9:
            		;	// Stops C# compiler whinging that label 'loop9' has no statements


            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 190:33: -> paramList(list=$e)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("paramList",
            	    new STAttrMap().Add("list", list_e));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "paramList"

    public class deviceMemberID_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "deviceMemberID"
    // LPMEDLuaCodeGen.g:192:1: deviceMemberID : DEVICEID (ids+= ID )+ -> members(objectname=$DEVICEID.textmembersname=$ids);
    public LPMEDLuaCodeGen.deviceMemberID_return deviceMemberID() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.deviceMemberID_return retval = new LPMEDLuaCodeGen.deviceMemberID_return();
        retval.Start = input.LT(1);

        CommonTree DEVICEID32 = null;
        CommonTree ids = null;
        IList list_ids = null;

        try 
    	{
            // LPMEDLuaCodeGen.g:192:17: ( DEVICEID (ids+= ID )+ -> members(objectname=$DEVICEID.textmembersname=$ids))
            // LPMEDLuaCodeGen.g:192:19: DEVICEID (ids+= ID )+
            {
            	DEVICEID32=(CommonTree)Match(input,DEVICEID,FOLLOW_DEVICEID_in_deviceMemberID989); if (state.failed) return retval;
            	// LPMEDLuaCodeGen.g:192:31: (ids+= ID )+
            	int cnt10 = 0;
            	do 
            	{
            	    int alt10 = 2;
            	    int LA10_0 = input.LA(1);

            	    if ( (LA10_0 == ID) )
            	    {
            	        alt10 = 1;
            	    }


            	    switch (alt10) 
            		{
            			case 1 :
            			    // LPMEDLuaCodeGen.g:192:31: ids+= ID
            			    {
            			    	ids=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceMemberID993); if (state.failed) return retval;
            			    	if (list_ids == null) list_ids = new ArrayList();
            			    	list_ids.Add(ids);


            			    }
            			    break;

            			default:
            			    if ( cnt10 >= 1 ) goto loop10;
            			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            		            EarlyExitException eee =
            		                new EarlyExitException(10, input);
            		            throw eee;
            	    }
            	    cnt10++;
            	} while (true);

            	loop10:
            		;	// Stops C# compiler whinging that label 'loop10' has no statements



            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 192:37: -> members(objectname=$DEVICEID.textmembersname=$ids)
            	  {
            	      retval.ST = templateLib.GetInstanceOf("members",
            	    new STAttrMap().Add("objectname", ((DEVICEID32 != null) ? DEVICEID32.Text : null)).Add("membersname", list_ids));
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "deviceMemberID"

    protected class deviceFuncID_scope 
    {
        protected internal //virtual pins of method (or list of pins of several methods)
         int pout;
        protected internal int statePin;
        protected internal string signal;
    }
    protected Stack deviceFuncID_stack = new Stack();

    public class deviceFuncID_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "deviceFuncID"
    // LPMEDLuaCodeGen.g:194:1: deviceFuncID : ( ^( CCALL ^( CASYNCCALL ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sm= ID ) ) ) -> asyncCall(vpout=$deviceFuncID::poutsignal=$deviceFuncID::signal) | ^( CCALL ^( CENDTHECALL ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sm= ID ) ) ) -> endone(vpout=$deviceFuncID::pout));
    public LPMEDLuaCodeGen.deviceFuncID_return deviceFuncID() // throws RecognitionException [1]
    {   
        deviceFuncID_stack.Push(new deviceFuncID_scope());
        LPMEDLuaCodeGen.deviceFuncID_return retval = new LPMEDLuaCodeGen.deviceFuncID_return();
        retval.Start = input.LT(1);

        CommonTree devname = null;
        CommonTree sm = null;
        CommonTree nodes = null;
        IList list_nodes = null;

        try 
    	{
            // LPMEDLuaCodeGen.g:201:1: ( ^( CCALL ^( CASYNCCALL ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sm= ID ) ) ) -> asyncCall(vpout=$deviceFuncID::poutsignal=$deviceFuncID::signal) | ^( CCALL ^( CENDTHECALL ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sm= ID ) ) ) -> endone(vpout=$deviceFuncID::pout))
            int alt13 = 2;
            int LA13_0 = input.LA(1);

            if ( (LA13_0 == CCALL) )
            {
                int LA13_1 = input.LA(2);

                if ( (LA13_1 == DOWN) )
                {
                    int LA13_2 = input.LA(3);

                    if ( (LA13_2 == CASYNCCALL) )
                    {
                        alt13 = 1;
                    }
                    else if ( (LA13_2 == CENDTHECALL) )
                    {
                        alt13 = 2;
                    }
                    else 
                    {
                        if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                        NoViableAltException nvae_d13s2 =
                            new NoViableAltException("", 13, 2, input);

                        throw nvae_d13s2;
                    }
                }
                else 
                {
                    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                    NoViableAltException nvae_d13s1 =
                        new NoViableAltException("", 13, 1, input);

                    throw nvae_d13s1;
                }
            }
            else 
            {
                if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                NoViableAltException nvae_d13s0 =
                    new NoViableAltException("", 13, 0, input);

                throw nvae_d13s0;
            }
            switch (alt13) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:227:2: ^( CCALL ^( CASYNCCALL ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sm= ID ) ) )
                    {
                    	Match(input,CCALL,FOLLOW_CCALL_in_deviceFuncID1037); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,CASYNCCALL,FOLLOW_CASYNCCALL_in_deviceFuncID1040); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,OBJECTNAME,FOLLOW_OBJECTNAME_in_deviceFuncID1043); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	devname=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceFuncID1047); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	Match(input,NODES,FOLLOW_NODES_in_deviceFuncID1051); if (state.failed) return retval;

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	    // LPMEDLuaCodeGen.g:227:61: (nodes+= ID )*
                    	    do 
                    	    {
                    	        int alt11 = 2;
                    	        int LA11_0 = input.LA(1);

                    	        if ( (LA11_0 == ID) )
                    	        {
                    	            alt11 = 1;
                    	        }


                    	        switch (alt11) 
                    	    	{
                    	    		case 1 :
                    	    		    // LPMEDLuaCodeGen.g:227:61: nodes+= ID
                    	    		    {
                    	    		    	nodes=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceFuncID1055); if (state.failed) return retval;
                    	    		    	if (list_nodes == null) list_nodes = new ArrayList();
                    	    		    	list_nodes.Add(nodes);


                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop11;
                    	        }
                    	    } while (true);

                    	    loop11:
                    	    	;	// Stops C# compiler whining that label 'loop11' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return retval;
                    	}
                    	Match(input,MEMBERNAME,FOLLOW_MEMBERNAME_in_deviceFuncID1060); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	sm=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceFuncID1064); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) 
                    	{

                    	                          FindVPinsByMethodName(
                    	          	                ((program_scope)program_stack.Peek()).DDname,
                    	  	                        devname.Text,
                    	  				list_nodes,
                    	  	                        ((sm != null) ? sm.Text : null),
                    	          	                out ((deviceFuncID_scope)deviceFuncID_stack.Peek()).statePin,
                    	  				out ((deviceFuncID_scope)deviceFuncID_stack.Peek()).pout,
                    	  				out ((deviceFuncID_scope)deviceFuncID_stack.Peek()).signal);
                    	  	        
                    	}


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 238:3: -> asyncCall(vpout=$deviceFuncID::poutsignal=$deviceFuncID::signal)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("asyncCall",
                    	    new STAttrMap().Add("vpout", ((deviceFuncID_scope)deviceFuncID_stack.Peek()).pout).Add("signal", ((deviceFuncID_scope)deviceFuncID_stack.Peek()).signal));
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:253:3: ^( CCALL ^( CENDTHECALL ^( OBJECTNAME devname= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sm= ID ) ) )
                    {
                    	Match(input,CCALL,FOLLOW_CCALL_in_deviceFuncID1098); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,CENDTHECALL,FOLLOW_CENDTHECALL_in_deviceFuncID1101); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	Match(input,OBJECTNAME,FOLLOW_OBJECTNAME_in_deviceFuncID1104); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	devname=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceFuncID1108); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	Match(input,NODES,FOLLOW_NODES_in_deviceFuncID1112); if (state.failed) return retval;

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	    // LPMEDLuaCodeGen.g:253:63: (nodes+= ID )*
                    	    do 
                    	    {
                    	        int alt12 = 2;
                    	        int LA12_0 = input.LA(1);

                    	        if ( (LA12_0 == ID) )
                    	        {
                    	            alt12 = 1;
                    	        }


                    	        switch (alt12) 
                    	    	{
                    	    		case 1 :
                    	    		    // LPMEDLuaCodeGen.g:253:63: nodes+= ID
                    	    		    {
                    	    		    	nodes=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceFuncID1116); if (state.failed) return retval;
                    	    		    	if (list_nodes == null) list_nodes = new ArrayList();
                    	    		    	list_nodes.Add(nodes);


                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop12;
                    	        }
                    	    } while (true);

                    	    loop12:
                    	    	;	// Stops C# compiler whining that label 'loop12' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return retval;
                    	}
                    	Match(input,MEMBERNAME,FOLLOW_MEMBERNAME_in_deviceFuncID1121); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	sm=(CommonTree)Match(input,ID,FOLLOW_ID_in_deviceFuncID1125); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) 
                    	{

                    	                          FindVPinsByMethodName(
                    	   	                       	((program_scope)program_stack.Peek()).DDname,
                    	  	     	               	devname.Text,
                    	  				list_nodes,
                    	  	                        ((sm != null) ? sm.Text : null),
                    	           	                out ((deviceFuncID_scope)deviceFuncID_stack.Peek()).statePin,
                    	  				out ((deviceFuncID_scope)deviceFuncID_stack.Peek()).pout,
                    	  				out ((deviceFuncID_scope)deviceFuncID_stack.Peek()).signal);
                    	                  
                    	}


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 264:3: -> endone(vpout=$deviceFuncID::pout)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("endone",
                    	    new STAttrMap().Add("vpout", ((deviceFuncID_scope)deviceFuncID_stack.Peek()).pout));
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
            deviceFuncID_stack.Pop();
        }
        return retval;
    }
    // $ANTLR end "deviceFuncID"

    protected class functionCall_scope 
    {
        protected internal List<int> parameters;
    }
    protected Stack functionCall_stack = new Stack();

    public class functionCall_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "functionCall"
    // LPMEDLuaCodeGen.g:286:1: functionCall : ( ^( CASYNCFUNCCALL ID (parms+= parameter )* ) -> asyncFuncCall(name=$ID.textpars=$parms) | ^( CWAITFUNCFINISH ID (parms+= parameter )* ) -> waitFuncFinish(name=$ID.text) | ^( CSYNCFUNCCALL ID (parms+= parameter )* ) -> syncFuncCall(name=$ID.textpars=$parms));
    public LPMEDLuaCodeGen.functionCall_return functionCall() // throws RecognitionException [1]
    {   
        functionCall_stack.Push(new functionCall_scope());
        LPMEDLuaCodeGen.functionCall_return retval = new LPMEDLuaCodeGen.functionCall_return();
        retval.Start = input.LT(1);

        CommonTree ID33 = null;
        CommonTree ID34 = null;
        CommonTree ID35 = null;
        IList list_parms = null;
        RuleReturnScope parms = null;
        try 
    	{
            // LPMEDLuaCodeGen.g:291:1: ( ^( CASYNCFUNCCALL ID (parms+= parameter )* ) -> asyncFuncCall(name=$ID.textpars=$parms) | ^( CWAITFUNCFINISH ID (parms+= parameter )* ) -> waitFuncFinish(name=$ID.text) | ^( CSYNCFUNCCALL ID (parms+= parameter )* ) -> syncFuncCall(name=$ID.textpars=$parms))
            int alt17 = 3;
            switch ( input.LA(1) ) 
            {
            case CASYNCFUNCCALL:
            	{
                alt17 = 1;
                }
                break;
            case CWAITFUNCFINISH:
            	{
                alt17 = 2;
                }
                break;
            case CSYNCFUNCCALL:
            	{
                alt17 = 3;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d17s0 =
            	        new NoViableAltException("", 17, 0, input);

            	    throw nvae_d17s0;
            }

            switch (alt17) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:292:4: ^( CASYNCFUNCCALL ID (parms+= parameter )* )
                    {
                    	Match(input,CASYNCFUNCCALL,FOLLOW_CASYNCFUNCCALL_in_functionCall1171); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	ID33=(CommonTree)Match(input,ID,FOLLOW_ID_in_functionCall1173); if (state.failed) return retval;
                    	// LPMEDLuaCodeGen.g:292:29: (parms+= parameter )*
                    	do 
                    	{
                    	    int alt14 = 2;
                    	    int LA14_0 = input.LA(1);

                    	    if ( (LA14_0 == PARAM) )
                    	    {
                    	        alt14 = 1;
                    	    }


                    	    switch (alt14) 
                    		{
                    			case 1 :
                    			    // LPMEDLuaCodeGen.g:292:29: parms+= parameter
                    			    {
                    			    	PushFollow(FOLLOW_parameter_in_functionCall1177);
                    			    	parms = parameter();
                    			    	state.followingStackPointer--;
                    			    	if (state.failed) return retval;
                    			    	if (list_parms == null) list_parms = new ArrayList();
                    			    	list_parms.Add(parms.Template);


                    			    }
                    			    break;

                    			default:
                    			    goto loop14;
                    	    }
                    	} while (true);

                    	loop14:
                    		;	// Stops C# compiler whining that label 'loop14' has no statements


                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 292:43: -> asyncFuncCall(name=$ID.textpars=$parms)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("asyncFuncCall",
                    	    new STAttrMap().Add("name", ((ID33 != null) ? ID33.Text : null)).Add("pars", list_parms));
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:293:6: ^( CWAITFUNCFINISH ID (parms+= parameter )* )
                    {
                    	Match(input,CWAITFUNCFINISH,FOLLOW_CWAITFUNCFINISH_in_functionCall1201); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	ID34=(CommonTree)Match(input,ID,FOLLOW_ID_in_functionCall1203); if (state.failed) return retval;
                    	// LPMEDLuaCodeGen.g:293:32: (parms+= parameter )*
                    	do 
                    	{
                    	    int alt15 = 2;
                    	    int LA15_0 = input.LA(1);

                    	    if ( (LA15_0 == PARAM) )
                    	    {
                    	        alt15 = 1;
                    	    }


                    	    switch (alt15) 
                    		{
                    			case 1 :
                    			    // LPMEDLuaCodeGen.g:293:32: parms+= parameter
                    			    {
                    			    	PushFollow(FOLLOW_parameter_in_functionCall1207);
                    			    	parms = parameter();
                    			    	state.followingStackPointer--;
                    			    	if (state.failed) return retval;
                    			    	if (list_parms == null) list_parms = new ArrayList();
                    			    	list_parms.Add(parms.Template);


                    			    }
                    			    break;

                    			default:
                    			    goto loop15;
                    	    }
                    	} while (true);

                    	loop15:
                    		;	// Stops C# compiler whining that label 'loop15' has no statements


                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 293:46: -> waitFuncFinish(name=$ID.text)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("waitFuncFinish",
                    	    new STAttrMap().Add("name", ((ID34 != null) ? ID34.Text : null)));
                    	  }

                    	}
                    }
                    break;
                case 3 :
                    // LPMEDLuaCodeGen.g:294:5: ^( CSYNCFUNCCALL ID (parms+= parameter )* )
                    {
                    	Match(input,CSYNCFUNCCALL,FOLLOW_CSYNCFUNCCALL_in_functionCall1225); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	ID35=(CommonTree)Match(input,ID,FOLLOW_ID_in_functionCall1227); if (state.failed) return retval;
                    	// LPMEDLuaCodeGen.g:294:29: (parms+= parameter )*
                    	do 
                    	{
                    	    int alt16 = 2;
                    	    int LA16_0 = input.LA(1);

                    	    if ( (LA16_0 == PARAM) )
                    	    {
                    	        alt16 = 1;
                    	    }


                    	    switch (alt16) 
                    		{
                    			case 1 :
                    			    // LPMEDLuaCodeGen.g:294:29: parms+= parameter
                    			    {
                    			    	PushFollow(FOLLOW_parameter_in_functionCall1231);
                    			    	parms = parameter();
                    			    	state.followingStackPointer--;
                    			    	if (state.failed) return retval;
                    			    	if (list_parms == null) list_parms = new ArrayList();
                    			    	list_parms.Add(parms.Template);


                    			    }
                    			    break;

                    			default:
                    			    goto loop16;
                    	    }
                    	} while (true);

                    	loop16:
                    		;	// Stops C# compiler whining that label 'loop16' has no statements


                    	Match(input, Token.UP, null); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 294:43: -> syncFuncCall(name=$ID.textpars=$parms)
                    	  {
                    	      retval.ST = templateLib.GetInstanceOf("syncFuncCall",
                    	    new STAttrMap().Add("name", ((ID35 != null) ? ID35.Text : null)).Add("pars", list_parms));
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
            functionCall_stack.Pop();
        }
        return retval;
    }
    // $ANTLR end "functionCall"

    public class parameter_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "parameter"
    // LPMEDLuaCodeGen.g:298:1: parameter : ^( PARAM parameterValue ) -> {$parameterValue.st};
    public LPMEDLuaCodeGen.parameter_return parameter() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.parameter_return retval = new LPMEDLuaCodeGen.parameter_return();
        retval.Start = input.LT(1);

        LPMEDLuaCodeGen.parameterValue_return parameterValue36 = default(LPMEDLuaCodeGen.parameterValue_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:298:11: ( ^( PARAM parameterValue ) -> {$parameterValue.st})
            // LPMEDLuaCodeGen.g:299:2: ^( PARAM parameterValue )
            {
            	Match(input,PARAM,FOLLOW_PARAM_in_parameter1260); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	PushFollow(FOLLOW_parameterValue_in_parameter1262);
            	parameterValue36 = parameterValue();
            	state.followingStackPointer--;
            	if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 299:26: -> {$parameterValue.st}
            	  {
            	      retval.ST = ((parameterValue36 != null) ? parameterValue36.ST : null);
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "parameter"

    protected class parameterValue_scope 
    {
        protected internal int value;
    }
    protected Stack parameterValue_stack = new Stack();

    public class parameterValue_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "parameterValue"
    // LPMEDLuaCodeGen.g:302:1: parameterValue : ( ID -> {%{$ID.Text}} | INT -> {%{$INT.Text}} | ^( OBJECTNAME name= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sname= ID ) -> {%{$parameterValue::value.ToString()}});
    public LPMEDLuaCodeGen.parameterValue_return parameterValue() // throws RecognitionException [1]
    {   
        parameterValue_stack.Push(new parameterValue_scope());
        LPMEDLuaCodeGen.parameterValue_return retval = new LPMEDLuaCodeGen.parameterValue_return();
        retval.Start = input.LT(1);

        CommonTree name = null;
        CommonTree sname = null;
        CommonTree ID37 = null;
        CommonTree INT38 = null;
        CommonTree nodes = null;
        IList list_nodes = null;


        	((parameterValue_scope)parameterValue_stack.Peek()).value =  0;

        try 
    	{
            // LPMEDLuaCodeGen.g:311:1: ( ID -> {%{$ID.Text}} | INT -> {%{$INT.Text}} | ^( OBJECTNAME name= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sname= ID ) -> {%{$parameterValue::value.ToString()}})
            int alt19 = 3;
            switch ( input.LA(1) ) 
            {
            case ID:
            	{
                alt19 = 1;
                }
                break;
            case INT:
            	{
                alt19 = 2;
                }
                break;
            case OBJECTNAME:
            	{
                alt19 = 3;
                }
                break;
            	default:
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d19s0 =
            	        new NoViableAltException("", 19, 0, input);

            	    throw nvae_d19s0;
            }

            switch (alt19) 
            {
                case 1 :
                    // LPMEDLuaCodeGen.g:312:4: ID
                    {
                    	ID37=(CommonTree)Match(input,ID,FOLLOW_ID_in_parameterValue1288); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 312:7: -> {%{$ID.Text}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,ID37.Text);
                    	  }

                    	}
                    }
                    break;
                case 2 :
                    // LPMEDLuaCodeGen.g:313:6: INT
                    {
                    	INT38=(CommonTree)Match(input,INT,FOLLOW_INT_in_parameterValue1306); if (state.failed) return retval;


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 313:10: -> {%{$INT.Text}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,INT38.Text);
                    	  }

                    	}
                    }
                    break;
                case 3 :
                    // LPMEDLuaCodeGen.g:314:5: ^( OBJECTNAME name= ID ) ^( NODES (nodes+= ID )* ) ^( MEMBERNAME sname= ID )
                    {
                    	Match(input,OBJECTNAME,FOLLOW_OBJECTNAME_in_parameterValue1324); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	name=(CommonTree)Match(input,ID,FOLLOW_ID_in_parameterValue1328); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	Match(input,NODES,FOLLOW_NODES_in_parameterValue1332); if (state.failed) return retval;

                    	if ( input.LA(1) == Token.DOWN )
                    	{
                    	    Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	    // LPMEDLuaCodeGen.g:314:40: (nodes+= ID )*
                    	    do 
                    	    {
                    	        int alt18 = 2;
                    	        int LA18_0 = input.LA(1);

                    	        if ( (LA18_0 == ID) )
                    	        {
                    	            alt18 = 1;
                    	        }


                    	        switch (alt18) 
                    	    	{
                    	    		case 1 :
                    	    		    // LPMEDLuaCodeGen.g:314:40: nodes+= ID
                    	    		    {
                    	    		    	nodes=(CommonTree)Match(input,ID,FOLLOW_ID_in_parameterValue1336); if (state.failed) return retval;
                    	    		    	if (list_nodes == null) list_nodes = new ArrayList();
                    	    		    	list_nodes.Add(nodes);


                    	    		    }
                    	    		    break;

                    	    		default:
                    	    		    goto loop18;
                    	        }
                    	    } while (true);

                    	    loop18:
                    	    	;	// Stops C# compiler whining that label 'loop18' has no statements


                    	    Match(input, Token.UP, null); if (state.failed) return retval;
                    	}
                    	Match(input,MEMBERNAME,FOLLOW_MEMBERNAME_in_parameterValue1341); if (state.failed) return retval;

                    	Match(input, Token.DOWN, null); if (state.failed) return retval;
                    	sname=(CommonTree)Match(input,ID,FOLLOW_ID_in_parameterValue1345); if (state.failed) return retval;

                    	Match(input, Token.UP, null); if (state.failed) return retval;
                    	if ( state.backtracking == 0 ) 
                    	{
                    	   ((parameterValue_scope)parameterValue_stack.Peek()).value =  GetNamedStateValue(name.Text, list_nodes, sname.Text);
                    	}


                    	// TEMPLATE REWRITE
                    	if ( state.backtracking==0 )
                    	{
                    	  // 316:5: -> {%{$parameterValue::value.ToString()}}
                    	  {
                    	      retval.ST = new StringTemplate(templateLib,((parameterValue_scope)parameterValue_stack.Peek()).value.ToString());
                    	  }

                    	}
                    }
                    break;

            }
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
            parameterValue_stack.Pop();
        }
        return retval;
    }
    // $ANTLR end "parameterValue"

    public class varDecList_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "varDecList"
    // LPMEDLuaCodeGen.g:324:1: varDecList : ( varDecListAtom )+ ;
    public LPMEDLuaCodeGen.varDecList_return varDecList() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.varDecList_return retval = new LPMEDLuaCodeGen.varDecList_return();
        retval.Start = input.LT(1);

        try 
    	{
            // LPMEDLuaCodeGen.g:324:12: ( ( varDecListAtom )+ )
            // LPMEDLuaCodeGen.g:324:14: ( varDecListAtom )+
            {
            	// LPMEDLuaCodeGen.g:324:14: ( varDecListAtom )+
            	int cnt20 = 0;
            	do 
            	{
            	    int alt20 = 2;
            	    int LA20_0 = input.LA(1);

            	    if ( (LA20_0 == CTYPE) )
            	    {
            	        alt20 = 1;
            	    }


            	    switch (alt20) 
            		{
            			case 1 :
            			    // LPMEDLuaCodeGen.g:324:14: varDecListAtom
            			    {
            			    	PushFollow(FOLLOW_varDecListAtom_in_varDecList1375);
            			    	varDecListAtom();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return retval;

            			    }
            			    break;

            			default:
            			    if ( cnt20 >= 1 ) goto loop20;
            			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            		            EarlyExitException eee =
            		                new EarlyExitException(20, input);
            		            throw eee;
            	    }
            	    cnt20++;
            	} while (true);

            	loop20:
            		;	// Stops C# compiler whinging that label 'loop20' has no statements


            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "varDecList"

    public class varDecListAtom_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "varDecListAtom"
    // LPMEDLuaCodeGen.g:326:1: varDecListAtom : ^( CTYPE TYPE peremDecList ) ;
    public LPMEDLuaCodeGen.varDecListAtom_return varDecListAtom() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.varDecListAtom_return retval = new LPMEDLuaCodeGen.varDecListAtom_return();
        retval.Start = input.LT(1);

        try 
    	{
            // LPMEDLuaCodeGen.g:326:16: ( ^( CTYPE TYPE peremDecList ) )
            // LPMEDLuaCodeGen.g:326:19: ^( CTYPE TYPE peremDecList )
            {
            	Match(input,CTYPE,FOLLOW_CTYPE_in_varDecListAtom1387); if (state.failed) return retval;

            	Match(input, Token.DOWN, null); if (state.failed) return retval;
            	Match(input,TYPE,FOLLOW_TYPE_in_varDecListAtom1389); if (state.failed) return retval;
            	PushFollow(FOLLOW_peremDecList_in_varDecListAtom1391);
            	peremDecList();
            	state.followingStackPointer--;
            	if (state.failed) return retval;

            	Match(input, Token.UP, null); if (state.failed) return retval;

            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "varDecListAtom"

    public class peremDecList_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "peremDecList"
    // LPMEDLuaCodeGen.g:328:1: peremDecList : ( ID )+ ;
    public LPMEDLuaCodeGen.peremDecList_return peremDecList() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.peremDecList_return retval = new LPMEDLuaCodeGen.peremDecList_return();
        retval.Start = input.LT(1);

        try 
    	{
            // LPMEDLuaCodeGen.g:328:14: ( ( ID )+ )
            // LPMEDLuaCodeGen.g:328:16: ( ID )+
            {
            	// LPMEDLuaCodeGen.g:328:16: ( ID )+
            	int cnt21 = 0;
            	do 
            	{
            	    int alt21 = 2;
            	    int LA21_0 = input.LA(1);

            	    if ( (LA21_0 == ID) )
            	    {
            	        alt21 = 1;
            	    }


            	    switch (alt21) 
            		{
            			case 1 :
            			    // LPMEDLuaCodeGen.g:328:16: ID
            			    {
            			    	Match(input,ID,FOLLOW_ID_in_peremDecList1402); if (state.failed) return retval;

            			    }
            			    break;

            			default:
            			    if ( cnt21 >= 1 ) goto loop21;
            			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            		            EarlyExitException eee =
            		                new EarlyExitException(21, input);
            		            throw eee;
            	    }
            	    cnt21++;
            	} while (true);

            	loop21:
            		;	// Stops C# compiler whinging that label 'loop21' has no statements


            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "peremDecList"

    public class block_return : TreeRuleReturnScope
    {
        private StringTemplate st;
        public StringTemplate ST    { get { return st; } set { st = value; } }
        public override object Template 		{ get { return st; } }
        public override string ToString() 		{ return (st == null) ? null : st.ToString(); }
    };

    // $ANTLR start "block"
    // LPMEDLuaCodeGen.g:330:1: block : ( varDecList )* blockStmt -> {$blockStmt.st};
    public LPMEDLuaCodeGen.block_return block() // throws RecognitionException [1]
    {   
        LPMEDLuaCodeGen.block_return retval = new LPMEDLuaCodeGen.block_return();
        retval.Start = input.LT(1);

        LPMEDLuaCodeGen.blockStmt_return blockStmt39 = default(LPMEDLuaCodeGen.blockStmt_return);


        try 
    	{
            // LPMEDLuaCodeGen.g:330:7: ( ( varDecList )* blockStmt -> {$blockStmt.st})
            // LPMEDLuaCodeGen.g:330:9: ( varDecList )* blockStmt
            {
            	// LPMEDLuaCodeGen.g:330:9: ( varDecList )*
            	do 
            	{
            	    int alt22 = 2;
            	    int LA22_0 = input.LA(1);

            	    if ( (LA22_0 == CTYPE) )
            	    {
            	        alt22 = 1;
            	    }


            	    switch (alt22) 
            		{
            			case 1 :
            			    // LPMEDLuaCodeGen.g:330:10: varDecList
            			    {
            			    	PushFollow(FOLLOW_varDecList_in_block1412);
            			    	varDecList();
            			    	state.followingStackPointer--;
            			    	if (state.failed) return retval;

            			    }
            			    break;

            			default:
            			    goto loop22;
            	    }
            	} while (true);

            	loop22:
            		;	// Stops C# compiler whining that label 'loop22' has no statements

            	PushFollow(FOLLOW_blockStmt_in_block1416);
            	blockStmt39 = blockStmt();
            	state.followingStackPointer--;
            	if (state.failed) return retval;


            	// TEMPLATE REWRITE
            	if ( state.backtracking==0 )
            	{
            	  // 330:33: -> {$blockStmt.st}
            	  {
            	      retval.ST = ((blockStmt39 != null) ? blockStmt39.ST : null);
            	  }

            	}
            }

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "block"

    // Delegated rules


	private void InitializeCyclicDFAs()
	{
	}

 

    public static readonly BitSet FOLLOW_CPROGRAM_in_program71 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_CDEVICE_in_program74 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_program78 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_block_in_program83 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CSTATEMENT_in_blockStmt111 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_stmt_in_blockStmt115 = new BitSet(new ulong[]{0x0000000F60011F08UL});
    public static readonly BitSet FOLLOW_assign_in_stmt144 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ifStmt_in_stmt154 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CWHILE_in_stmt165 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_stmt167 = new BitSet(new ulong[]{0x0000000000000100UL});
    public static readonly BitSet FOLLOW_blockStmt_in_stmt169 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CFOR_in_stmt189 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_assign_in_stmt193 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_stmt195 = new BitSet(new ulong[]{0x0000000000000400UL});
    public static readonly BitSet FOLLOW_assign_in_stmt199 = new BitSet(new ulong[]{0x0000000000000100UL});
    public static readonly BitSet FOLLOW_blockStmt_in_stmt201 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_deviceFuncID_in_stmt228 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_blockStmt_in_stmt238 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CBREAKPOINT_in_stmt249 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_INT_in_stmt251 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_regMethodAccess_in_stmt269 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CTERMINATEALL_in_stmt279 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_functionCall_in_stmt291 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CREGMETHACCESS_in_regMethodAccess307 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_regMethodAccess309 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_regMethodAccess311 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CIFTE_in_ifStmt347 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_ifStmt349 = new BitSet(new ulong[]{0x0000000000000100UL});
    public static readonly BitSet FOLLOW_blockStmt_in_ifStmt353 = new BitSet(new ulong[]{0x0000000000000108UL});
    public static readonly BitSet FOLLOW_blockStmt_in_ifStmt357 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CASSIGN_in_assign387 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_assign389 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000090040UL});
    public static readonly BitSet FOLLOW_comExpr_in_assign391 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_assignExpr_in_comExpr417 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CASSIGNOP_in_assignExpr435 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_assignExpr437 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_assignExpr439 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_expr_in_assignExpr448 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_OpOr_in_expr474 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr478 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr482 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpAnd_in_expr505 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr509 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr513 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpLogicalB_in_expr536 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr540 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr544 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpLogicalA_in_expr572 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr576 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr580 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpAddSub_in_expr608 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr612 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr616 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpDivMul_in_expr644 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr648 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr652 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpNegation_in_expr680 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr685 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_OpUnar_in_expr705 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_expr709 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_83_in_expr728 = new BitSet(new ulong[]{0x0001FE00920E0000UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_expr_in_expr732 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000100000UL});
    public static readonly BitSet FOLLOW_84_in_expr734 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_atom_in_expr752 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_ID_in_atom784 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_CINT_in_atom795 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_INT_in_atom797 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CBOOL_in_atom809 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_DBOOL_in_atom811 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CFLOAT_in_atom823 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_FLOAT_in_atom825 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_regFuncAccess_in_atom836 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_OBJECTNAME_in_atom848 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_atom854 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NODES_in_atom858 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_atom864 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_MEMBERNAME_in_atom869 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_atom875 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CGETSTATE_in_atom901 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_OBJECTNAME_in_atom904 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_atom908 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NODES_in_atom912 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_atom916 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_CREGFUNCACCESS_in_regFuncAccess942 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_regFuncAccess944 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CPARAM_in_paramList966 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_expr_in_paramList970 = new BitSet(new ulong[]{0x0001FE00920E0008UL,0x0000000000080040UL});
    public static readonly BitSet FOLLOW_DEVICEID_in_deviceMemberID989 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_ID_in_deviceMemberID993 = new BitSet(new ulong[]{0x0000000000000002UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_CCALL_in_deviceFuncID1037 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_CASYNCCALL_in_deviceFuncID1040 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_OBJECTNAME_in_deviceFuncID1043 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_deviceFuncID1047 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NODES_in_deviceFuncID1051 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_deviceFuncID1055 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_MEMBERNAME_in_deviceFuncID1060 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_deviceFuncID1064 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CCALL_in_deviceFuncID1098 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_CENDTHECALL_in_deviceFuncID1101 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_OBJECTNAME_in_deviceFuncID1104 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_deviceFuncID1108 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NODES_in_deviceFuncID1112 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_deviceFuncID1116 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_MEMBERNAME_in_deviceFuncID1121 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_deviceFuncID1125 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_CASYNCFUNCCALL_in_functionCall1171 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_functionCall1173 = new BitSet(new ulong[]{0x0000004000000008UL});
    public static readonly BitSet FOLLOW_parameter_in_functionCall1177 = new BitSet(new ulong[]{0x0000004000000008UL});
    public static readonly BitSet FOLLOW_CWAITFUNCFINISH_in_functionCall1201 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_functionCall1203 = new BitSet(new ulong[]{0x0000004000000008UL});
    public static readonly BitSet FOLLOW_parameter_in_functionCall1207 = new BitSet(new ulong[]{0x0000004000000008UL});
    public static readonly BitSet FOLLOW_CSYNCFUNCCALL_in_functionCall1225 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_functionCall1227 = new BitSet(new ulong[]{0x0000004000000008UL});
    public static readonly BitSet FOLLOW_parameter_in_functionCall1231 = new BitSet(new ulong[]{0x0000004000000008UL});
    public static readonly BitSet FOLLOW_PARAM_in_parameter1260 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_parameterValue_in_parameter1262 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ID_in_parameterValue1288 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_INT_in_parameterValue1306 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_OBJECTNAME_in_parameterValue1324 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_parameterValue1328 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_NODES_in_parameterValue1332 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_parameterValue1336 = new BitSet(new ulong[]{0x0000000000000008UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_MEMBERNAME_in_parameterValue1341 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_ID_in_parameterValue1345 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_varDecListAtom_in_varDecList1375 = new BitSet(new ulong[]{0x0000000000000042UL});
    public static readonly BitSet FOLLOW_CTYPE_in_varDecListAtom1387 = new BitSet(new ulong[]{0x0000000000000004UL});
    public static readonly BitSet FOLLOW_TYPE_in_varDecListAtom1389 = new BitSet(new ulong[]{0x0000000000000000UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_peremDecList_in_varDecListAtom1391 = new BitSet(new ulong[]{0x0000000000000008UL});
    public static readonly BitSet FOLLOW_ID_in_peremDecList1402 = new BitSet(new ulong[]{0x0000000000000002UL,0x0000000000000040UL});
    public static readonly BitSet FOLLOW_varDecList_in_block1412 = new BitSet(new ulong[]{0x0000000000000140UL});
    public static readonly BitSet FOLLOW_blockStmt_in_block1416 = new BitSet(new ulong[]{0x0000000000000002UL});

}
}